/*
 * Form.h
 *
 *  Created on: 18.2.2013
 *      Author: Travis
 */

#pragma once

#ifdef _WIN32 
#include <windows.h> 
#include "SDL.h"
#include "SDL_thread.h"
#else
#include "SDL/SDL.h"
#include "SDL/SDL_thread.h"
#endif

#include <glm/glm.hpp>
#include "Picture2D.h"
#include <string>
#include <vector>
#include "../dataTypes/Rectangle2D.h"
#include "../console/globalConsole.h"

// event types
#define FORM_EVENT_MOUSE_OVER				1
#define FORM_EVENT_MOUSE_CLICK_LEFT			2
#define FORM_EVENT_MOUSE_CLICK_RIGHT		3

namespace Gadgets
{

class Form
{
public:
	Form(int _width, int _height);
	virtual ~Form();

	// draw form if it's visible
	virtual void draw();

	// set form backgroud
	void setBackground(std::string file);

	// add new item to form
	void addItem(Form *form);

	// delete all items
	// only free mem, no delete call
	void deleteItems();

	// return cout of items in form
	int getCountOfItems();

	// events
	// control of form
	virtual void control(SDL_Event *event);

	// mouse over event
	virtual void MouseOver(SDL_Event *event, int x, int y);
	//
	int getHeight();
	void setHeight(int height);
	glm::vec2 getPos();
	void setPos(glm::vec2 pos);
	int getPosX();
	int getPosY();
	void setPos(int x, int y);
	int getWidth();
	void setWidth(int width);
	bool isVisible() const;
	void setVisible(bool visible);
	std::vector<Form*> getItems();
	void setItems(std::vector<Form*> items);

	void setRoot(Form *r);

	// set mouse over status
	void setMouseInside(bool s);
	bool getMouseInside();

	//	set data2 in event
	// you can send another pointer or something
	void setUserData2(void * data);

	// events
	SDL_Event MouseOverEvent;
	//-------------------

	glm::vec2 Pos;
	int width, height;

	Picture2D *background;

protected:
	// address to root form 
	Form *root;

	std::vector<Form*> items;

	bool visible, mouseInside;
};

} /* namespace Gadgets */
